package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节子流程
 * @author 代码创建
 */
public class FlowStepSubflow extends AbstractTableBean {

	private String StepId; //环节ID
	private String FlowId; //流程ID
	private String SubflowReSave; //初始化子流程
	private String SubflowSelect; //可选择子流程
	private String SubflowShowALL; //是否全部显示

	public static String TABLE_NAME = "Flow_StepSubflow";
	public static String TABLEKEY_NAME = "StepId";
	public FlowStepSubflow (IntegrateSql f){
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
	}

	public FlowStepSubflow (IntegrateSql f,ResultSet rs) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		this.initParamToRs(rs);
	}

	public FlowStepSubflow (IntegrateSql f,String keyValue) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		setCodePrepare(selectCodeById().toString());
		prepareSql.setPstValue(1, keyValue);
		ResultSet rs = executeQuery();
		if(rs.next()){
			initParamToRs(rs);
		}else{
			initParam();
		}
		rs.close();
	}

	@Override
	protected void initParam() {
		StepId = ""; //环节ID
		FlowId = ""; //流程ID
		SubflowReSave = ""; //初始化子流程
		SubflowSelect = ""; //可选择子流程
		SubflowShowALL = ""; //是否全部显示
	}


	public void initParamToRs(ResultSet rs) throws SQLException{
		StepId = rs.getString("StepId"); //环节ID
		FlowId = rs.getString("FlowId"); //流程ID
		SubflowReSave = rs.getString("SubflowReSave"); //初始化子流程
		SubflowSelect = rs.getString("SubflowSelect"); //可选择子流程
		SubflowShowALL = rs.getString("SubflowShowALL"); //是否全部显示
		this.setKeyId(rs.getString("StepId"));
	}


	@Override
	protected int appendData() throws SQLException {
		int i = 1;
		prepareSql.setPstValue(i++,StepId); //环节ID
		prepareSql.setPstValue(i++,FlowId); //流程ID
		prepareSql.setPstValue(i++,SubflowReSave); //初始化子流程
		prepareSql.setPstValue(i++,SubflowSelect); //可选择子流程
		prepareSql.setPstValue(i++,SubflowShowALL); //是否全部显示
		return i;
	}


	@Override
	public Vector<String> getFields() {
		Vector<String> vec = new Vector<String>();
		vec.addElement("StepId"); //环节ID
		vec.addElement("FlowId"); //流程ID
		vec.addElement("SubflowReSave"); //初始化子流程
		vec.addElement("SubflowSelect"); //可选择子流程
		vec.addElement("SubflowShowALL"); //是否全部显示
		return vec;
	}


	/**
	 * 设置环节ID
	 * @param stepid
	 */
	public void setStepId(String stepid){
		StepId = stepid;
	}
	/**
	 * 获取StepId
	 * @return 环节ID
	 */
	public String getStepId(){
		return StepId;
	}

	/**
	 * 设置流程ID
	 * @param flowid
	 */
	public void setFlowId(String flowid){
		FlowId = flowid;
	}
	/**
	 * 获取FlowId
	 * @return 流程ID
	 */
	public String getFlowId(){
		return FlowId;
	}

	/**
	 * 设置初始化子流程
	 * @param subflowresave
	 */
	public void setSubflowReSave(String subflowresave){
		SubflowReSave = subflowresave;
	}
	/**
	 * 获取SubflowReSave
	 * @return 初始化子流程
	 */
	public String getSubflowReSave(){
		return SubflowReSave;
	}

	/**
	 * 设置可选择子流程
	 * @param subflowselect
	 */
	public void setSubflowSelect(String subflowselect){
		SubflowSelect = subflowselect;
	}
	/**
	 * 获取SubflowSelect
	 * @return 可选择子流程
	 */
	public String getSubflowSelect(){
		return SubflowSelect;
	}

	/**
	 * 设置是否全部显示
	 * @param subflowshowall
	 */
	public void setSubflowShowALL(String subflowshowall){
		SubflowShowALL = subflowshowall;
	}
	/**
	 * 获取SubflowShowALL
	 * @return 是否全部显示
	 */
	public String getSubflowShowALL(){
		return SubflowShowALL;
	}

}
